<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <!--<link href="__STATIC__/admin/assets/css/ace.css" rel="stylesheet">-->
    <link href="__STATIC__/admin/assets/css/vendor/bootstrap/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="__STATIC__/admin/assets/font-awesome/css/font-awesome.min.css">
    <!--引入多选样式-->
    <link rel="stylesheet" href="__STATIC__/admin/assets/css/bootstrap-multiselect.css" type="text/css">
    <!--引入时间插件-->
    <link rel="stylesheet" href="__STATIC__/daterangepicker/daterangepicker.css"/>
</head>
<style>
    .content{
        margin: 20px;
    }
    .row{
        margin-left: 0px;
        margin-right: 0px;
    }
    .col-xs-1, .col-xs-2, .col-xs-3, .col-xs-4, .col-xs-5, .col-xs-6, .col-xs-7, .col-xs-8, .col-xs-9, .col-xs-10, .col-xs-11, .col-xs-12{
        padding-left: 0;
        padding-right: 0;
    }
    .btn-group,.multiselect{
        width: 100%;
    }
    .margin-bottom-10{
        margin-bottom: 10px;
    }
    .form-control{
        padding: 6px;
    }
    .sear-box{
        float: left;
    }
    .distro{
        width: 100%;
        float: left;
        padding-top: 20px;
        margin-top: 10px;
        border-top: 1px solid #ccc;
    }
    .table{
        width:95%;
        text-align: center;
        border: 1px solid #ccc;
        margin: 0 2.5%;
    }
    .table thead tr th,.table tbody tr td{
        text-align: center;
    }
    .table thead tr th input{
        /*position: absolute;*/
    }
    .table thead tr th label{
        margin: 0;
        margin-left: 20px;
    }
    form{
        float: left;
    }
    .reset{
        width: 15%;
        float: right;
        margin-top: -45px;
    }
    .reset .btn{
        border: 1px solid #ccc;
    }
</style>
<body>
<div class="content" >
    <div class="row">
        <form  class="sear-box" id="serform"  method="get"  action="{:url('batch')}">
            <div class="col-xs-12">
                <div class="col-xs-6 set-block" id="a-id" data-id="3">
                    <div class="col-xs-4">
                        <div class="btn-group margin-bottom-10">
                            <button type="button" class="no-bor form-control" style="border: 0 !important;box-shadow: none;">
                                唯一标识：
                            </button>
                        </div>
                    </div>
                    <div class="col-xs-8">
                        <div class="btn-group margin-bottom-10">
                            <input type="text" class="form-control search" value="{$form.only}" name="only"  id="id" placeholder="ID/姓名/电话/微信">
                        </div>
                    </div>
                </div>

                <div class="col-xs-6 set-block" id="a-single" data-id="2">
                    <div class="col-xs-4">
                        <div class="btn-group margin-bottom-10">
                            <button type="button" class="no-bor form-control" style="border: 0 !important;box-shadow: none;">
                                录入时间：
                            </button>
                        </div>
                    </div>
                    <div class="col-xs-8 ">
                        <div class="btn-group margin-bottom-10">
                            <input type="text" class="form-control search" value="{$form.jdtime}" id="single" name="jdtime" placeholder="录入时间" id="test1">
                        </div>
                    </div>
                </div>

                <!--<div class="col-xs-6 set-block" id="a-category" data-id="9">-->
                    <!--<div class="col-xs-4">-->
                        <!--<div class="btn-group margin-bottom-10">-->
                            <!--<button type="button" class="no-bor form-control" style="border: 0 !important;box-shadow: none;">-->
                                <!--订单类别：-->
                            <!--</button>-->
                        <!--</div>-->
                    <!--</div>-->
                    <!--<div class="col-xs-8">-->
                        <!--<input type="hidden" name="leibie" id="category_text">-->
                        <!--<select id="category"  multiple="multiple" style="display: none;">-->
                            <!--{volist name="leibie" id="vb"}-->
                            <!--<option value="{$vb.id}" {in name="vb.id" value="$form['leibie']" } selected="selected" {/in}>{$vb.title}</option>-->
                            <!--{/volist}-->
                        <!--</select>-->
                    <!--</div>-->
                <!--</div>-->

                <div class="col-xs-6 set-block" id="a-category" data-id="9">
                    <div class="col-xs-4">
                        <div class="btn-group margin-bottom-10">
                            <button type="button" class="no-bor form-control" style="border: 0 !important;box-shadow: none;">
                                拍摄方式：
                            </button>
                        </div>
                    </div>
                    <div class="col-xs-8">
                        <input type="hidden" name="shot_mode" id="shot_mode_text">
                        <select id="shot_mode" multiple="multiple" style="display: none;">
                            {volist name="shotmode" id="vb"}
                            <option value="{$vb.id}" {in name="vb.id" value="$form['shot_mode']" } selected="selected" {/in}>{$vb.title}</option>
                            {/volist}
                        </select>
                    </div>
                </div>

                <div class="col-xs-6  set-block" id="a-channel" data-id="8">
                    <div class="col-xs-4">
                        <div class="btn-group margin-bottom-10">
                            <button type="button" class="no-bor form-control" style="border: 0 !important;box-shadow: none;">
                                渠道：
                            </button>
                        </div>
                    </div>
                    <div class="col-xs-8">
                        <input type="hidden" name="channel" id="channel_text">
                        <select id="channel"  multiple="multiple" style="display: none;">
                            {volist name="channel" id="va"}
                            <option value="{$va.id}"  {in name="va.id" value="$form['channel']" } selected="selected" {/in}>{$va.title}</option>
                            {/volist}
                        </select>
                    </div>
                </div>

                <div class="col-xs-6 set-block" id="a-intentionality" data-id="16">
                    <div class="col-xs-4">
                        <div class="btn-group margin-bottom-10">
                            <button type="button" class="no-bor form-control" style="border: 0 !important;box-shadow: none;">
                                意向度：
                            </button>
                        </div>
                    </div>
                    <div class="col-xs-8">
                        <div class="btn-group margin-bottom-10">
                            <input type="hidden" name="intention" id="intention_text">
                            <select  id="intention"  multiple="multiple" class="dropdown-toggle form-control" style="display: none;">
                                {volist name="yixiang" id="vc"}
                                <option value="{$vc.id}"  {in name="vc.id" value="$form['intention']" } selected="selected" {/in} >{$vc.title}</option>
                                {/volist}
                            </select>
                        </div>
                    </div>
                </div>
                <div class="col-xs-6  set-block" id="a-banji" data-id="8">
                    <div class="col-xs-4">
                        <div class="btn-group margin-bottom-10">
                            <button type="button" class="no-bor form-control" style="border: 0 !important;box-shadow: none;">
                                班级：
                            </button>
                        </div>
                    </div>
                    <div class="col-xs-8">
                        <input type="hidden" name="banji" id="banji_text">
                        <select class="form-control" id="banji" multiple="multiple" style="display: none !important;">
                            {volist name="banji" id="data"}
                            <option value="{$data.id}" {in name="data.id" value="$form['banji']"}selected="selected" {/in}>{$data.banjiname}</option>
                            {/volist}
                        </select>
                    </div>
                </div>
                <div class="col-xs-4 col-xs-offset-2 search-active" style="float: right">
                    <div class="col-xs-6">
                        <div class="btn-group margin-bottom-10">
                            <button type="submit" class="btn form-control" onclick="search()" style="background-color: #428bca;color: #fff;">
                                <i class="fa fa-search" aria-hidden="true"></i>
                                查询
                            </button>
                        </div>
                    </div>
                </div>
            </div>
        </form>

        <form class="reset"  method="get"  action="{:url('batch')}">
            <div class="col-xs-12" style="clear: both">
                <div class="btn-group">
                    <button type="submit" class="btn  form-control" onclick="formReset()">
                        <i class="fa fa-refresh" aria-hidden="true"></i>
                        重置
                    </button>
                </div>
            </div>
        </form>
        <div  class="distro">
            <div class="col-xs-12">
                <div class="col-xs-6" id="distr-box">
                    <div class="col-xs-12 set-block">
                        <div class="col-xs-4">
                            <div class="btn-group margin-bottom-10">
                                <button type="button" class="no-bor form-control" style="border: 0 !important;box-shadow: none;">
                                    邀约组：
                                </button>
                            </div>
                        </div>
                        <div class="col-xs-8">
                            <div class="btn-group margin-bottom-10">
                                <select  id="invitation_group" name="yykf_group" class="dropdown-toggle form-control" style="display: none">
                                    <option value="0">未分配邀约组</option>
                                    {volist name="yykf_group" id="vc"}
                                    <option value="{$vc.id}"  {in name="vc.id" value="$form['yykf_group']" } selected="selected" {/in} >{$vc.name}</option>
                                    {/volist}
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-12 set-block">
                        <div class="col-xs-4">
                            <div class="btn-group margin-bottom-10">
                                <button type="button" class="no-bor form-control" style="border: 0 !important;box-shadow: none;">
                                    邀约客服：
                                </button>
                            </div>
                        </div>
                        <div class="col-xs-8">
                            <div class="btn-group margin-bottom-10">
                                <select  id="invit" name="yykf1" class="dropdown-toggle form-control select_all ">
                                    {volist name="yykf" id="vc"}
                                    <option value="{$vc.id}"  {in name="vc.id" value="$form['yykf']" } selected="selected" {/in} >{$vc.username}</option>
                                    {/volist}
                                </select>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-xs-4 col-xs-offset-2  distr-active">
                    <div class="col-xs-6">
                        <div class="btn-group margin-bottom-10">
                            <button  class="btn form-control" onclick="batch()" style="background-color: #428bca;color: #fff;">
                                <i class="fa fa-sitemap" aria-hidden="true"></i>
                                分配
                            </button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div>
    <table id="sample-table-1" class="table table-striped table-bordered table-hover">
        <thead>
        <tr>
            <th width="8%"><input type="checkbox" id="checkall"></th>
            <th>编号</th>
            <th>姓名</th>
            <th>渠道</th>
            <th>意向</th>
            <!--<th>类别</th>-->
            <th>拍摄方式</th>
            <th>建单时间</th>
        </tr>
        </thead>
        <tbody>
        {volist name='list' id='info'}
            <tr>
                <td><input type="checkbox" value="{$info.id}" id="opt0" name="choice"></td>
                <td>{$info.id}</td>
                <td>{$info.name_z}</td>
                <td>{$info.channel_text}</td>
                <td>{$info.intention_text}</td>
                <!--<td>{$info.leibie_text}</td>-->
                <td>{$info.shot_mode_text}</td>
                <td>{$info.jdtime}</td>
            </tr>
        {/volist}
        </tbody>
    </table>
    <!-- /row -->
    <div class="page" style="text-align:center;">
        {$page}
    </div>
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="__STATIC__/admin/assets/js/jquery.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="__STATIC__/admin/assets/js/vendor/bootstrap/bootstrap.min.js"></script>
<!--引入框架-->
<!--<script src="__STATIC__/admin/assets/js/ace/ace.js"></script>-->
<!--<script src="__STATIC__/admin/assets/js/ace/ace.searchbox-autocomplete.js"></script>-->
<!--引入多选-start-->
<script type="text/javascript" src="__STATIC__/admin/multiselect/docs/js/prettify.js"></script>
<script type="text/javascript" src="__STATIC__/admin/multiselect/dist/js/bootstrap-multiselect.js"></script>
<!--引入多选-end-->
<!--引入时间插件-->
<!--<script type="text/javascript" src="__STATIC__/common/laydate/laydate.js"></script>-->
<script type="text/javascript" src="__STATIC__/daterangepicker/moment.min.js"></script>
<script type="text/javascript" src="__STATIC__/daterangepicker/daterangepicker.js"></script>
<!--配置时间插件自定义-->
<script type="text/javascript" src="__STATIC__/daterangepicker/rangedate.js"></script>
<script type="text/javascript" src="__STATIC__/common/laydate/laydate.js"></script>
<!--引入layer插件-->
<script type="text/javascript" src="__STATIC__/common/layer/layer.js"></script>
<script>
    var optiontext=[
        ['订单状态'],['订单类别'],['渠道'],['来源'],['拍摄地点'],['意向度'],['升序'],['邀约组'],['邀约人员'],['建单人员'],['拍摄方式'],['班级']
    ];
    var options={
        nonSelectedText: '',           //未选择时显示文本
        enableFiltering: true,                 //是否启用搜索功能
        filterPlaceholder: '搜索',              //当启用搜索功能后，搜索文本框的提示内容
        includeSelectAllOption: true,          //是否启用全选功能
        selectAllText: '全选',                //全选选项显示文本
        maxHeight: 400,                       //下拉菜单最大高度
        allSelectedText: '全选',              //全选时显示文本
        selectAllNumber: true,               //是否显示选中个数
        //  buttonWidth: '120px',                 //按钮最大宽度
        nSelectedText: '个已选中' ,           //显示选中4个以后显示文本
        enableClickableOptGroups: true
    };
    // 渠道来源
    var options1={
        nonSelectedText: '渠道',           //未选择时显示文本
        enableFiltering: true,                 //是否启用搜索功能
        filterPlaceholder: '搜索',              //当启用搜索功能后，搜索文本框的提示内容
        includeSelectAllOption: true,          //是否启用全选功能
        selectAllText: '全选',                //全选选项显示文本
        maxHeight: 400,                       //下拉菜单最大高度
        allSelectedText: '全选',              //全选时显示文本
        selectAllNumber: true,               //是否显示选中个数
        //  buttonWidth: '120px',                 //按钮最大宽度
        nSelectedText: '个已选中' ,           //显示选中4个以后显示文本
        enableClickableOptGroups: true,
        onDropdownHide: function (event) {
            $('#channel_text').val($('#channel').val());
            var channel = $('#channel_text').val();
            var obj = $('#source');
            getsource(channel,obj);
        },
    };
    ACTID = [];
    /*全选事件*/
    $('#checkall').click(function(){
        //判断apple是否被选中
        ACTID = [];
        var bischecked=$('#checkall').is(':checked');
        var choice=$('input[name="choice"]');
        bischecked ? choice.prop('checked',true) : choice.prop('checked',false);
        $('input[name="choice"]:checked').each(function(){
            var value=$(this).val();
            ACTID.push(value);
        });
    });
     // 单选复选框事件
    /*$('input[name="choice"]').click(function () {
        var value = $(this).val();
        if($(this).prop("checked")){
            ACTID.push(value);
        }else{
            removeByValue(ACTID,value);
        }
    });*/

    // 从数组中删除指定元素
    function removeByValue(arr, val) {
        for(var i=0; i<arr.length; i++) {
            if(arr[i] == val) {
                arr.splice(i, 1);
                break;

            }
        }
    }

    $(document).ready(function() {
        // 初始化下拉菜单
        options.nonSelectedText=optiontext[0];
        $('#state').multiselect(options);
        options.nonSelectedText=optiontext[1];
        $('#category').multiselect(options);
        options.nonSelectedText=optiontext[2];
        $('#channel').multiselect(options1);
        options.nonSelectedText=optiontext[3];
        $('#source').multiselect(options);
        options.nonSelectedText=optiontext[4];
        $('#place').multiselect(options);
        options.nonSelectedText=optiontext[5];
        $('#intention').multiselect(options);
        options.nonSelectedText=optiontext[6];
        $('#multiple7').multiselect(options);

        options.nonSelectedText=optiontext[9];
        $('#personnel').multiselect(options);
        options.nonSelectedText=optiontext[7];
        $('#invitation_group').multiselect(options);
        options.nonSelectedText=optiontext[8];
        $('#invit1').multiselect(options);
        options.nonSelectedText=optiontext[10];
        $('#shot_mode').multiselect(options);
        options.nonSelectedText=optiontext[11];
        $('#banji').multiselect(options);
        //activecontains(dateblock);

    });

    /*根据渠道获取来源*/
    function getsource(data,obj) {
        if(data != '') {
            $.post("{:url('common/getSourceByChennel')}", {channel: data}, function (result) {
                var html = "";
                obj.html('');
                // console.log(result)
                if (result == '') {
                    html += "<option value='0'>暂无数据</option>";
                    obj.append(html);
                } else {
                    for (var i = 0; i < result.length; i++) {
                        html += "<option value=" + result[i].id + ">" + result[i].title + "</option>"
                    }
                    obj.append(html);
                }
                options.nonSelectedText = optiontext[3];
                $("#source").multiselect("destroy").multiselect(options);
            });
            var banji = $('#banji');
            $.post("{:url('common/getBanjiBySource')}", {source: data}, function (result) {
                var html = "";
                banji.html('');
                // console.log(result);
                // return false;
                if (result == '') {
                    html += "<option value='0' selected='selected'>暂无班级</option>";
                    banji.append(html);
                }else if(result.code==0){
                    return false;
                } else {
                    $.each(eval(result), function (i, n) {
                        $("<option value='" + n.id + "'>" + n.banjiname + "</optinon>").appendTo(banji);
                    });
                }
                options.nonSelectedText=optiontext[11];
                $('#banji').multiselect("destroy").multiselect(options);
                banji.hide();
            })
        }
    }
    /*修改客资获取对应的邀约组员*/
    $('#invitation_group').change(function () {
        var id = $('#invitation_group').val();
        var divs = $('#invit');
        groupinvit(id, divs);

    });
    //邀约人员获取
    function groupinvit(id, obj ,invit){
        $.post("{:url('common/getuserByGroup')}", {depart_id: id}, function (result) {
            var html = '';
            obj.html('');
            if (id == '0') {
                html += "<option value=''>未分配邀约</option>";
            } else {
                if(result.length !=0){
                    for (var i in result) {
                        if (invit == result[i].id) {
                            html += "<option value='" + result[i].id + "' selected  >" + result[i].username + "</option>";
                        } else {
                            html += "<option value='" + result[i].id + "'>" + result[i].username + "</option>";
                        }
                    }
                }else {
                    html += "<option value='' selected='selected'>暂无邀约人员</option>";
                }

            }
            obj.append(html);
        });
    }

    /*搜索按钮点击事件*/
    function search() {
        var channel = $('#channel').val();
        $('#channel_text').val(channel);

        var intention = $('#intention').val();
        $('#intention_text').val(intention);

        var category = $('#category').val();
        $('#category_text').val(category);

        var shot_mode = $('#shot_mode').val();
        $('#shot_mode_text').val(shot_mode);

        var personnel = $('#personnel').val();
        $('#personnel_text').val(personnel);

        var banji = $('#banji').val();
        $('#banji_text').val(banji);
    }

    $(".table tbody tr").click(function() {
        var value = $(this).find('td').first().find('input').val();
        var hasSelected = $(this).hasClass("blue");
        $(this)[hasSelected ? "removeClass" : "addClass"]("blue").find(":checkbox").prop("checked", !hasSelected);
        if($(this).find('td').first().find('input').prop("checked")){
            ACTID.push(value);
        }else{
            removeByValue(ACTID,value);
        }
        // console.log(ACTID)


    })

    // 分单
    function batch() {
        var invitation_group = $('#invitation_group').val();
        var invitation = $('#invit').val();
        if(invitation<1){
            layer.msg('请选择邀约客服', {time: 2000, icon:3});return false;};
        if(invitation_group<1){layer.msg('请选择邀约客组', {time: 2000, icon:3});return false;};
        if(ACTID<1){layer.msg('请选择要分配的客资', {time: 2000, icon:3});return false;};
        $.post("{:url('batchall')}", {id: ACTID,invitation:invitation,invitation_group:invitation_group}, function (result) {
            layer.msg(result.info, {icon: result.status});
            setTimeout(function(){
                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                parent.layer.close(index); //再执行关闭
                window.parent.location.reload();
            },2000); //延迟演示
        });
    }


</script>
</body>
</html>